package reflect;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * 通过反射机制来实例化对象
 * */
public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个类名:");
        String name = sc.nextLine();

        Class cls1 = Class.forName(name);
        Object obj = cls1.newInstance();
        System.out.println(obj);
        Object obj1 = new ArrayList<>();
        System.out.println(obj1);
    }
}
